﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace Videotagger
{
    class Prefs
    {
        private static string XML_FILE_NAME = "settings.xml";
        private static string ROOT_ELEMENT = "settings";


        public string fileListPath { get; private set; }

        public Prefs()
        {
            fileListPath = null;
        }


        public void Load()
        {
            FileInfo fileInfo = new FileInfo(XML_FILE_NAME);

            //test purpose only
            if (fileInfo.Exists)
                fileInfo.Delete();


            if (!fileInfo.Exists)
            {
                Init();
            }
        }

        public void Init()
        {
            XmlTextWriter textWriter = new XmlTextWriter(XML_FILE_NAME, null);
            textWriter.WriteStartDocument();
            
            // Write first element

            textWriter.WriteStartElement(ROOT_ELEMENT);

               /* textWriter.WriteStartElement("r", "RECORD", "urn:record");
                // Write next element
                textWriter.WriteStartElement("Name", "");
                textWriter.WriteString("Student");
                textWriter.WriteEndElement();
                // Write one more element
                textWriter.WriteStartElement("Address", ""); textWriter.WriteString("Colony");
                textWriter.WriteEndElement();
                // WriteChars
                char[] ch = new char[3];
                ch[0] = 'a';
                ch[1] = 'r';
                ch[2] = 'c';
                textWriter.WriteStartElement("Char");
                textWriter.WriteChars(ch, 0, ch.Length);*/
            textWriter.WriteEndElement(); // End ROOT_ELEMENT
            textWriter.WriteEndDocument();
            textWriter.Close();
        }
    }
}
